import Koa from 'koa'
import Router from 'koa-router'

import config from '@config/index'
import InitManager from '@core/init'

const app = new Koa()
const router = new Router()

// 健康检查路由
router.get('/health', async (ctx) => {
  ctx.body = { status: 'ok' }
})

app.use(router.routes())
app.use(router.allowedMethods())

InitManager.initCore(app)

app.listen(config.port, () => {
  console.log('\x1b[35m%s\x1b[0m', `🚀 服务正常启动运行 >>  http://localhost:${config.port}`)
})
